﻿using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Babylon.Primitives
{
    /// <summary>
    /// Vertex data with color
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct VertexPositionNormalColor  : IPositionNormal
    {
        private Vector3 _position;
        private Vector3 _normal;
        private Color _color;

        /// <summary>
        /// Get or set the position
        /// </summary>
        public Vector3 Position { get { return _position; } set { _position = value; } }

        /// <summary>
        /// Get or set the normal
        /// </summary>
        public Vector3 Normal { get { return _normal; } set { _normal = value; } }

        /// <summary>
        /// get or set the color of the vertex
        /// </summary>
        public Color Color { get { return _color; } set { _color = value; } }


        static VertexDeclaration _vertexDeclaration = new VertexDeclaration(
            new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
            new VertexElement(3*sizeof(float), VertexElementFormat.Vector3, VertexElementUsage.Normal,0),
            new VertexElement(6*sizeof(float), VertexElementFormat.Color, VertexElementUsage.Color,0)
            );


        public static VertexDeclaration GetVertexDeclaration()
        {
            return _vertexDeclaration;
        }
    }
}
